import { createRouter, createWebHashHistory } from 'vue-router'

// 2. 定义一些路由
// 每个路由都需要映射到一个组件。
// 我们后面再讨论嵌套路由。
const routes = [
  { path: '/', name: 'login', component: () => import('../components/common/loginView.vue') },
  {
    path: '/index', // 教师主页
    name: 'teaherHome',
    component: () => import('../components/common/helloView.vue'),
    children: [
      {
        path: '/', // 首页默认路由
        component: () => import('../components/common/helloView.vue')
      },
      {
        path: '/grade', // 学生成绩
        component: () => import('../components/charts/gradeView.vue')
      },
      {
        path: '/selectExamToPart', // 学生分数段
        component: () => import('../components/teacher/selectExamToPart.vue')
      },
      {
        path: '/scorePart',
        component: () => import('../components/charts/scorePart.vue')
      },
      {
        path: '/allStudentsGrade', // 所有学生成绩统计
        component: () => import('../components/teacher/allStudentsGrade.vue')
      },
      {
        path: '/examDescription', // 考试管理功能描述
        component: () => import('../components/teacher/examDescription.vue')
      },
      {
        path: '/selectExam', // 查询所有考试
        component: () => import('../components/teacher/selectExam.vue')
      },
      {
        path: '/addExam', // 添加考试
        component: () => import('../components/teacher/addExam.vue')
      },
      {
        path: '/answerDescription', // 题库管理功能介绍
        component: () => import('../components/teacher/answerDescription.vue')
      },
      {
        path: '/selectAnswer', // 查询所有题库
        component: () => import('../components/teacher/selectAnswer.vue')
      },
      {
        path: '/addAnswer', // 增加题库主界面
        component: () => import('../components/teacher/addAnswer.vue')
      },
      {
        path: '/addAnswerChildren', // 点击试卷跳转到添加题库页面
        component: () => import('../components/teacher/addAnswerChildren.vue')
      },
      {
        path: '/studentManage', // 学生管理界面
        component: () => import('../components/teacher/studentManage.vue')
      },
      {
        path: '/addStudent', // 添加学生
        component: () => import('../components/teacher/addStudent.vue')
      }

    ]
  },
  {
    path: '/student',
    component: () => import('../components/student/indexView.vue'),
    children: [
      { path: '/myExam', component: () => import('../components/student/myExam.vue') },
      { path: '/startExam', component: () => import('../components/student/startExam.vue') },
      { path: '/manager', component: () => import('../components/student/managerView.vue') },
      { path: '/examMsg', name: 'ExamMsg', component: () => import('../components/student/examMsg.vue') },
      { path: '/message', component: () => import('../components/student/messageView.vue') },
      { path: '/studentScore', component: () => import('../components/student/answerScore.vue') },
      { path: '/scoreTable', component: () => import('../components/student/scoreTable.vue') }
    ]
  },
  { path: '/answer', component: () => import('../components/student/answerView.vue') }
]
// 3. 创建路由实例并传递 `routes` 配置
// 你可以在这里输入更多的配置，但我们在这里
// 暂时保持简单
const router = createRouter({
  // 4. 内部提供了 history 模式的实现。为了简单起见，我们在这里使用 hash 模式。
  history: createWebHashHistory(),
  routes // `routes: routes` 的缩写
})

export default router
